import axios from "axios"
import qs from "qs"

const api = axios.create({
    baseURL: process.env.NODE_ENV === "development" ? "/api" : "/bigScreen",
    timeout: 60000,
})

api.interceptors.response.use((response) => {
    return response.data
})

export const get = (url, params) => {
    return api({
        url: url,
        method: "get",
        params: params,
    })
}

export const post = (url, data) => {
    return api({
        url: url,
        method: "post",
        data: data,
    })
}

export const post_param = (url, params) => {
    return api({
        url: url,
        method: "post",
        data: qs.stringify(params),
    })
}

export default { get, post, post_param }
